package arch.chameleon.busi.sample.service.impl;

import java.util.List;

import org.springframework.transaction.annotation.Transactional;

import arch.chameleon.busi.sample.dao.SampleCpuDao;
import arch.chameleon.busi.sample.dao.SampleCpuSpecDao;
import arch.chameleon.busi.sample.dao.mybatis.SampleInfoDao;
import arch.chameleon.busi.sample.model.SampleCpu;
import arch.chameleon.busi.sample.model.SampleCpuSpec;
import arch.chameleon.busi.sample.model.SampleInfo;
import arch.chameleon.busi.sample.service.SampleService;

/**
 * @author George
 *
 */
@Transactional(readOnly=true)
public class SampleServiceImpl implements SampleService{

	@Transactional(readOnly=false)
	@Override
	public void save(SampleCpu cpuSample, SampleCpuSpec cpuSpecSample) {
		sampleCpuSpecDao.save(cpuSpecSample);
		sampleCpuDao.save(cpuSample);
	}

	@Override
	public List<SampleInfo> seletAll() {
		return sampleCpuDao.findAllSampleInfo();
	}

	@Transactional(readOnly=false)
	@Override
	public void remove(String id, String specId) {
		sampleCpuDao.delete(id);
		sampleCpuSpecDao.delete(specId);
	}
	
	@Override
	public List<SampleInfo> selectAllViaMybatis() {
		return sampleInfoDao.selectSampleInfo();
	}
	
	private SampleCpuDao sampleCpuDao;
	
	private SampleCpuSpecDao sampleCpuSpecDao;
	
	private SampleInfoDao sampleInfoDao;

	public void setSampleCpuDao(SampleCpuDao sampleCpuDao) {
		this.sampleCpuDao = sampleCpuDao;
	}

	public void setSampleCpuSpecDao(SampleCpuSpecDao sampleCpuSpecDao) {
		this.sampleCpuSpecDao = sampleCpuSpecDao;
	}

	public void setSampleInfoDao(SampleInfoDao sampleInfoDao) {
		this.sampleInfoDao = sampleInfoDao;
	}
	
	
}
